Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop parsing yara files when a syntax error s found. #1188

Closed

Conversation

ragusaa
Copy link
Contributor

@ragusaa ragusaa commented Feb 27, 2024

The yara parser can potentially overwrite heap buffers parsing invalid yara files. Exit on error to avoid this. These overwrites are only observed when running with address sanitization and mpool disabled.

…arse

The yara parser can potentially overwrite heap buffers parsing invalid yara files.
Exit on error to avoid this.  These overwrites are only observed when running
with address sanitization and mpool disabled.
@ragusaa ragusaa changed the title Stop parsing yara files when a syntax error s found Stop parsing yara files when a syntax error s found. Feb 27, 2024
@ragusaa
Copy link
Contributor Author

ragusaa commented Feb 27, 2024

I am not sure if this is a viable solution, but it does prevent the ossfuzz errors. This will require more testing.

Copy link
Contributor

@micahsnyder micahsnyder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix feels wrong for a couple reasons.

  1. this file is generated from the yara_grammar.y file, so changing this file won't have a lasting effect. I am unsure where the corresponding code is in the .y file.

  2. This code is derived from Yara project sources, here: https://github.com/VirusTotal/yara/blob/c009195c1e08da559600be94a78a14c2beb06d6b/libyara/grammar.c#L5325 I don't see a similar change here. Our source is way behind theirs and I assume they've since fixed it. We should really try to figure out how they fixed it, or else just work on upgrading to the latest sources and see if it resolves the issue.

My recommendation is to cancel this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants